package com.realtyManage.springboot.Service.impl;

import com.realtyManage.springboot.Dao.IndexHotHouseRepository;
import com.realtyManage.springboot.Model.Do.IndexHotHouse;
import com.realtyManage.springboot.Service.IIndexHotHouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.List;

/**
 * IndexHotHouseServiceImpl
 *
 * @Author 杭州素色网络科技有限公司
 * @Date 2019/5/7
 **/
@Service
@Transactional
public class IndexHotHouseServiceImpl implements IIndexHotHouseService{
    @Autowired
    private IndexHotHouseRepository indexHotHouseRepository;

    @Override
    public IndexHotHouse findById(int id) {
        return indexHotHouseRepository.findById(id).orElse(null);
    }

    @Override
    public boolean save(IndexHotHouse indexHotHouse) {
         if(indexHotHouseRepository.save(indexHotHouse)!=null){
             return true;
         }else{
             return false;
         }
    }

    @Override
    public List<IndexHotHouse> findByArea(String area) {
        return indexHotHouseRepository.findByArea(area);
    }

    @Override
    public List<IndexHotHouse> findByAreaLike(String area) {
        return indexHotHouseRepository.findByAreaLike("%"+area+"%");
    }

    @Override
    public List<IndexHotHouse> findAll() {
        return indexHotHouseRepository.findAll();
    }


    @Override
    public List<IndexHotHouse> findByAreaNotLike(String area) {
        return indexHotHouseRepository.findByAreaNotLike(area);
    }

    @Override
    public List<Integer> findByPeripheryLike(String area){
        return  indexHotHouseRepository.findByPeripheryLike(area);
    }

    @Override
    public String findHouseId(String houseId) {
        return indexHotHouseRepository.findHouseId(houseId);
    }

    @Override
    public String findLikeArea(String code){
        return  indexHotHouseRepository.findLikeArea(code);
    }
}
